<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>会员注册页面</title>
		<link type="text/css" rel="stylesheet" href="/static/css/style.css">
		<style type="text/css">
			.login_form {
				height: 420px;
				margin-top: 25px;
			}
		</style>
		<script src="/static/script/jquery.js"></script>
		<script>
			$(function () {
				$("#sub_btn").click(function () {
					//获取用户输入的用户名
					var username = $("#username").val();
					//设置验证用户名的正则表达式
					var usernameReg = /^[a-zA-Z0-9_-]{3,16}$/;
					//验证是否符合规则
					var flag = usernameReg.test(username);
					if (!flag) {
						alert("请输入3-16位的字母、数字、下划线或减号的用户名！");
						return false;
					}
					//获取用户输入的密码
					var password = $("#password").val();
					//设置验证密码的正则表达式
					var passwordReg = /^[a-zA-Z0-9_-]{6,18}$/;
					if (!passwordReg.test(password)) {
						alert("请输入6-18位的字母、数字、下划线或减号的密码！")
						return false;
					}
					//获取用户输入的确认密码
					var repwd = $("#repwd").val();
					if (repwd == "") {
						alert("确认密码不能为空！");
						return false;
					}
					//判断两次输入的密码是否一致
					if (repwd != password) {
						//将确认密码清空，即将确认密码密码框中的value属性设置为空
						$("#repwd").val("");
						alert("两次输入的密码不一致！");
						return false;
					}
					//获取用户输入的邮箱
					var email = $("#email").val();
					//设置验证邮箱的正则表达式
					var emailReg = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
					if (!emailReg.test(email)) {
						alert("邮箱格式不正确！");
						return false;
					}

				});
				$("#username").change(function () {
					var username = $(this).val();
					var url = "/refactor/user/checkUsername";
					var param = { "username": username };
					$.post(url, param, function (res) {
						$("#msg").show();
						$("#msg").html(res);
					});
				});
				$("#msg").hide();
				if ("{{.Status}}" == 40001) {
					$("#msg").show();
				}
			});
		</script>
	</head>

	<body>
		<div id="login_header">
			<!-- <img class="logo_img" alt="" src="/static/img/logo.gif" > -->
		</div>

		<div class="login_banner">

			<div id="l_content">
				<span class="login_word">欢迎注册</span>
			</div>

			<div id="content">
				<div class="login_form">
					<div class="login_box">
						<div class="tit">
							<h1>注册会员</h1>
							<span class="errorMsg" id="msg">{{.Msg}}</span>
						</div>
						<div class="form">
							<form action="/refactor/user/register" method="POST">
								<label>用户名称：</label>
								<input class="itxt" type="text" placeholder="请输入用户名" autocomplete="off" tabindex="1"
									name="username" id="username" />
								<br />
								<br />
								<label>用户密码：</label>
								<input class="itxt" type="password" placeholder="请输入密码" autocomplete="off" tabindex="1"
									name="password" id="password" />
								<br />
								<br />
								<label>确认密码：</label>
								<input class="itxt" type="password" placeholder="确认密码" autocomplete="off" tabindex="1"
									name="repwd" id="repwd" />
								<br />
								<br />
								<label>电子邮件：</label>
								<input class="itxt" type="text" placeholder="请输入邮箱地址" autocomplete="off" tabindex="1"
									name="email" id="email" />
								<br />
								<br />
								<label>手机号：&nbsp;&nbsp;&nbsp;</label>
								<input class="itxt" type="text" placeholder="请输入手机号" autocomplete="off" tabindex="1"
									name="phoneNum" id="phoneNum" />
								<br />
								<br />
								<input type="submit" value="注册" id="sub_btn" />
							</form>
						</div>

					</div>
				</div>
			</div>
		</div>
		<div id="bottom">
			<span>
				书城.Copyright &copy;2020.<a href="http://www.beian.miit.gov.cn/">鄂ICP备20002228号</a>
			</span>
		</div>
	</body>

</html>